//////////////////////////////////////////////////////////////////////
//!\file AlbumDataModel.hpp
//!\brief Scans start path for flac files, which are to be put into a vector aka album.
//!\author timmsusa@googlemail.com
//////////////////////////////////////////////////////////////////////

#ifndef COLLECTIONDATAMODEL_HPP
#define COLLECTIONDATAMODEL_HPP

#include <QObject>
#include <QDir>
#include <QFileInfo>
#include <QString>
#include <QVector>
#include <QStringList>
#include <QSet>
#include "Album.hpp"
#include "FlacTrack.hpp"
#include "FlacMetaDataManager.hpp"
#include "Persistence.hpp"

class AlbumDataModel: public QObject, public FlacMetadataManager
{
    Q_OBJECT

signals:
    void sigFlacFound(QString file);
    void sigInitFinished();

public:
    AlbumDataModel(const QString& path);
    ~AlbumDataModel();
    void initByPath(const QString& path);
    const QVector < Album >& getAlbumList()const;
    void requestStopScanDirs();

private:
    void addAlbum(const Album& album);
    void addFlacTrackToAlbum(const QFileInfo fi, Album& album);
    void scanDirsForAlbum(const QDir& dir);
    void deepScanForFlac( QDir dir, QVector < FlacTrack >& listOfFoundEntries );

public slots:
    void slotInitByPath(QString path);
    void slotDeepScanEnabled(bool enabled);
    void slotStopScanDirsRequested();

private:
    Persistence m_Persistence;
    bool m_DeepScanEnabled;
    QString m_Path;
    QVector < Album > m_FlacAlbumList;
    bool m_RequestStopScanDirs;
};

#endif // COLLECTIONDATAMODEL_HPP
